Skip to content

ios: support additional options pass from js #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 43 commits into from

Conversation

zxcpoiu
Copy link
Member

@zxcpoiu zxcpoiu commented Apr 24, 2020

Support addition options can pass from js method

updateDisplay

original:

updateDisplay = (uuid, displayName, handle)

new:

updateDisplay = (uuid, displayName, handle, options = null)
where the optional options could be:

{
  hasVideo: true,
  supportsHolding: true,
  supportsDTMF: true,
  supportsGrouping: true,
  supportsUngrouping: true,
} 

displayIncomingCall

original:

displayIncomingCall = (uuid, handle, localizedCallerName, handleType = 'number', hasVideo = false)

new:

displayIncomingCall = (uuid, handle, localizedCallerName, handleType = 'number', hasVideo = false, options = null)
where the optional options could be:

{
  supportsHolding: true,
  supportsDTMF: true,
  supportsGrouping: true,
  supportsUngrouping: true,
} 

Note for API compatibility:

Originally, displayIncomingCallalready has hasVideo argument but updateDisplay are not. For api compatibility, I did NOT move displayIncomingCall.hasVideo inside displayIncomingCall.options

In the earlier time, we've exposed native reportNewIncomingCall and introduced an overloading function for the new payloadargument for api compatibility:

Earlier Original (as simple api):

[RNCallKeep reportNewIncomingCall:uuid handle:handle handleType:@"generic" hasVideo:false localizedCallerName:callerName fromPushKit: YES];

and

Earlier New (as full api):

[RNCallKeep reportNewIncomingCall:uuid handle:handle handleType:@"generic" hasVideo:false localizedCallerName:callerName fromPushKit: YES payload:extra];

We can't have too much overloading functions, so I keep the original one, and extend the new overloading function, so now is:

This PR Original (as simple api):

[RNCallKeep reportNewIncomingCall:uuid handle:handle handleType:@"generic" hasVideo:false localizedCallerName:callerName fromPushKit: YES];

and

This PR New (as full api):

[RNCallKeep reportNewIncomingCall:uuid handle:handle handleType:@"generic" hasVideo:false localizedCallerName:callerName supportsHolding: YES supportsDTMF: YES supportsGrouping: YES supportsUngrouping: YES fromPushKit: YES payload: payload];

TL;DR

For user using native RNCallKeep reportNewIncomingCall with payload argument should change to [RNCallKeep reportNewIncomingCall:uuid handle:handle handleType:@"generic" hasVideo:false localizedCallerName:callerName supportsHolding: YES supportsDTMF: YES supportsGrouping: YES supportsUngrouping: YES fromPushKit: YES payload: payload];

@sboily
Copy link
Member

sboily commented Apr 28, 2020

Hello, does this features are possible on android? I haven't checked.

@sboily
Copy link
Member

sboily commented Apr 28, 2020

I checked the connection service API and looks like there is nothing to control that. options looks like generic, but what we want to do with android with this options? Does options need to be renamed to be more ios specific? Can you add the documentation on the README?

@zxcpoiu
Copy link
Member Author

zxcpoiu commented Apr 28, 2020

@sboily

Yes, on android, currently is no-op to the options.

About the naming, I just left it as it's original name of iOS because in the original api displayIncomingCall, there is an arguments called hasVideo which is no-op on android as well.
see here

I could change the name in the options with ios prefix indicating it's an ios specific option, like: iosHasVideo, but it looks like uncoordinated with the original hasVideo arg in displayIncomingCall described above.

Maybe we could change to like this?

let options = {
  ios: {
    hasVideo: true,
    supportsHolding: true,
    supportsDTMF: true,
    supportsGrouping: true,
    supportsUngrouping: true,
  }
} 

Because this PR related to api definition and slightly breaking change, so I will add document once we are all agreed the final api and this PR then :)

@danjenkins
Copy link
Collaborator

I think thats valid @zxcpoiu - its really difficult to merge everything into a combined API, I have partial video support going in Android but it really needs more work before I do a PR but we could just have an android key in the object - android doesnt support "supportsDTMF" for example... "supportsHolding" is done by capability flags passed into various things in connection service

@sboily
Copy link
Member

sboily commented Apr 28, 2020

Hello, i prefer this approach @zxcpoiu.

…comingCall. Which is usefull if you want to tell the pushkit you handled the VoIP notification only after the call was successfully reported.
@zxcpoiu
Copy link
Member Author

zxcpoiu commented Apr 29, 2020

@danjenkins @sboily

To confirm, we are saying that we prefer below approach, right?

let options = {
  ios: {
    hasVideo: true,
    supportsHolding: true,
    supportsDTMF: true,
    supportsGrouping: true,
    supportsUngrouping: true,
  }
} 

@danjenkins
Copy link
Collaborator

I am. We just can't hide the intrinsic differences between the platform's completely - android actually has a load more functionality not yet exposed!

@sboily
Copy link
Member

sboily commented Apr 29, 2020

Yes, i also confirm, thank you.

@manuquentin
Copy link
Contributor

@zxcpoiu can you rebase on master please ?

@zxcpoiu
Copy link
Member Author

zxcpoiu commented Apr 30, 2020

Done!

  • Changed to platform specific options
  • Add documents

If you want the api to be unified, I'm happy to move hasVideo arg of displayIncomingCall into options as well, but this introduced breaking changes to every user which invoke displayIncomingCall from js.

Let me know if anything need to change.

…-native

Separate react native part from rest of Android code
@manuquentin
Copy link
Contributor

manuquentin commented Jun 4, 2020

@zxcpoiu can you rebase it please ? So we can merge it.

@manuquentin
Copy link
Contributor

@zxcpoiu can you rebase your PR ? Thanks !

@zxcpoiu
Copy link
Member Author

zxcpoiu commented Jul 13, 2020

sorry for the delay, rebased.
But now seems guthub have some issue, the PR did not refreshed yet :(

@zxcpoiu
Copy link
Member Author

zxcpoiu commented Jul 13, 2020

But I noticed this PR needs to be discussed about the overloading api reportNewIncomingCall

Due to the addition of withCompletionHandler, now we have 3 overloading functions for backward compatibility:

Main functioon

main function should contains all arguments

https://github.com/react-native-webrtc/react-native-callkeep/blob/master/ios/RNCallKeep/RNCallKeep.m#L369

+ (void)reportNewIncomingCall:(NSString *)uuidString
                       handle:(NSString *)handle
                   handleType:(NSString *)handleType
                     hasVideo:(BOOL)hasVideo
          localizedCallerName:(NSString * _Nullable)localizedCallerName
                  fromPushKit:(BOOL)fromPushKit
                      payload:(NSDictionary * _Nullable)payload
        withCompletionHandler:(void (^_Nullable)(void))completion
{

Overloading 1

When we was adding payload, we introduced overloading function for user who is not using payload

https://github.com/react-native-webrtc/react-native-callkeep/blob/master/ios/RNCallKeep/RNCallKeep.m#L416

+ (void)reportNewIncomingCall:(NSString *)uuidString
                       handle:(NSString *)handle
                   handleType:(NSString *)handleType
                     hasVideo:(BOOL)hasVideo
          localizedCallerName:(NSString * _Nullable)localizedCallerName
                  fromPushKit:(BOOL)fromPushKit
{

Overloading 2

When we was adding withCompletionHandler, we introduced overloading function for user who is not using withCompletionHandler ( but using payload )

https://github.com/react-native-webrtc/react-native-callkeep/blob/master/ios/RNCallKeep/RNCallKeep.m#L358

+ (void)reportNewIncomingCall:(NSString *)uuidString
                       handle:(NSString *)handle
                   handleType:(NSString *)handleType
                     hasVideo:(BOOL)hasVideo
          localizedCallerName:(NSString * _Nullable)localizedCallerName
                  fromPushKit:(BOOL)fromPushKit
                      payload:(NSDictionary * _Nullable)payload
{

@zxcpoiu
Copy link
Member Author

zxcpoiu commented Jul 13, 2020

Main function should have all arguments for sure:

+ (void)reportNewIncomingCall:(NSString *)uuidString
                       handle:(NSString *)handle
                   handleType:(NSString *)handleType
                     hasVideo:(BOOL)hasVideo
          localizedCallerName:(NSString * _Nullable)localizedCallerName
              supportsHolding:(BOOL)supportsHolding
                 supportsDTMF:(BOOL)supportsDTMF
             supportsGrouping:(BOOL)supportsGrouping
           supportsUngrouping:(BOOL)supportsUngrouping
                  fromPushKit:(BOOL)fromPushKit
                      payload:(NSDictionary * _Nullable)payload
        withCompletionHandler:(void (^_Nullable)(void))completion
{

So now we have to decide:

what kind and how many overloading functions we should keep for api backward compatibility?

@sboily
Copy link
Member

sboily commented Jul 14, 2020

Hello @zxcpoiu, yes ! you right we need to cleanup a little that. We could probably release a new major version with some new features like #237 and #188 and removing some old backward compatibilities if there is no strong objection here. I think with these two PRs we have some interesting works to have video capabilities in callkeep for android and iOS.
Can you make a new tentative for updating the PR please?
Thank you!

@zxcpoiu zxcpoiu closed this Jul 14, 2020
@zxcpoiu zxcpoiu deleted the support_options branch July 14, 2020 09:43
@zxcpoiu zxcpoiu restored the support_options branch July 14, 2020 09:43
@zxcpoiu zxcpoiu deleted the support_options branch July 14, 2020 09:46
@zxcpoiu zxcpoiu restored the support_options branch July 14, 2020 09:46
@zxcpoiu zxcpoiu deleted the support_options branch July 14, 2020 09:46
@zxcpoiu zxcpoiu restored the support_options branch July 14, 2020 09:47
@zxcpoiu
Copy link
Member Author

zxcpoiu commented Jul 14, 2020

The commit history is getting funky on github, not sure why. force push and delete branch does't fix it.
I continued at #238

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants